@echo off
echo Starting to build Go project for Windows...

REM 设置目标操作系统和架构
set GOOS=windows
set GOARCH=amd64
set CGO_ENABLED=0

REM 配置输出文件名和路径（可自定义）
set OUTPUT_NAME=min.exe
set OUTPUT_DIR=.\output

REM 创建输出目录（如果不存在）
if not exist %OUTPUT_DIR% mkdir %OUTPUT_DIR%

REM 编译 Go 项目，指定入口文件
echo Building %OUTPUT_NAME% for Windows...
go build -o %OUTPUT_DIR%\%OUTPUT_NAME% main.go

REM 检查编译是否成功
if %ERRORLEVEL% EQU 0 (
    echo Build succeeded! Output: %OUTPUT_DIR%\%OUTPUT_NAME%
) else (
    echo Build failed with error code %ERRORLEVEL%
    exit /b %ERRORLEVEL%
)

REM 清理环境变量（可选）
set GOOS=
set GOARCH=
set CGO_ENABLED=
set OUTPUT_NAME=
set OUTPUT_DIR=

echo Done!
pause